<template>
  <div class="list-table">
    <el-form ref="queryForm" :model="queryParams" :inline="true">
      <el-form-item :label="$t('项目名称')" prop="dealName">
        <el-input
          v-model="queryParams.dealName"
          :placeholder="$t('项目名称')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item :label="$t('负责人')" prop="personChargeName">
        <el-input
          v-model="queryParams.personChargeName"
          :placeholder="$t('负责人')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item :label="$t('投资主体')" prop="investName">
        <el-input
          v-model="queryParams.investName"
          :placeholder="$t('投资主体')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item v-if="queryParams.dealType === 'bf'" :label="$t('管理公司')" prop="companyName">
        <el-input
          v-model="queryParams.companyName"
          :placeholder="$t('管理公司')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t("搜索") }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t("重置") }}</el-button>
        <el-button
          v-hasPermi="['deal:projectInvestmentSituation:exportReport']"
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="exportHandle"
        >{{ $t("导出") }}</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" tooltip-effect="darkTable" :data="dataList" border>
      <el-table-column :label="$t('序号')" align="center" show-overflow-tooltip min-width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('项目名称')" align="center" prop="dealName" show-overflow-tooltip min-width="180">
        <template slot-scope="scope">
          <router-link
            target="_blank"
            :to="{ path:'/deal/home/dealBaseHome', query: { id: scope.row.id, dealType: scope.row.dealType, companyId: scope.row.companyId, menuKey: 'deal_after' }}"
            class="link_a"
          >{{ scope.row.dealName }}</router-link>
        </template>
      </el-table-column>
      <el-table-column v-if="queryParams.dealType === 'bf'" :label="$t('管理公司')" align="center" prop="companyName" show-overflow-tooltip min-width="180">
        <template slot-scope="scope">
          <router-link
            target="_blank"
            :to="{path:'/company/base/companyBaseHome', query: { companyId: scope.row.companyId }}"
            class="link_a"
          >{{ scope.row.companyName }}</router-link>
        </template>
      </el-table-column>
      <el-table-column :label="$t('项目负责人')" align="center" prop="personChargeName" show-overflow-tooltip min-width="100" />
      <!-- 参股基金期限 -->
      <el-table-column v-if="queryParams.dealType === 'bf'" :label="$t('期限')" align="center" prop="bfFundTerm" show-overflow-tooltip min-width="100" />
      <el-table-column v-if="queryParams.dealType === 'bf'" :label="$t('基金规模') + this.$t('金额单位')" align="center" prop="subscribeScale" show-overflow-tooltip min-width="100">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.subscribeScale, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="queryParams.dealType === 'debt'" :label="$t('年化收益(%)')" align="center" prop="incomeRate" show-overflow-tooltip min-width="100" />
      <!-- 债权期限 -->
      <el-table-column v-if="queryParams.dealType === 'debt'" :label="$t('期限')" align="center" prop="debtPeriod" show-overflow-tooltip min-width="100" />
      <el-table-column v-if="queryParams.dealType === 'debt'" :label="$t('发行主体')" align="center" prop="issued" show-overflow-tooltip min-width="150" />
      <el-table-column v-if="queryParams.dealType === 'equity'" :label="$t('聚焦行业')" align="center" prop="industryFocus" show-overflow-tooltip min-width="150" />
      <el-table-column v-if="queryParams.dealType === 'equity'" :label="$t('持股比例(%)')" align="center" prop="shareholdingRation" show-overflow-tooltip min-width="100" />
      <el-table-column :label="$t('投资主体')" align="center" prop="investName" show-overflow-tooltip min-width="250" />
      <el-table-column :label="$t('预计总投资金额') + $t('金额单位')" align="center" prop="amountInvestmentEstimate" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.amountInvestmentEstimate, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('已付款金额') + $t('金额单位')" align="center" prop="amountInvestmentFact" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.amountInvestmentFact, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('已回收金额') + $t('金额单位')" align="center" prop="payBack" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.payBack, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('已回收本金') + $t('金额单位')" align="center" prop="returnPrincipal" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.returnPrincipal, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('已回收收益') + $t('金额单位')" align="center" prop="returnIncome" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.returnIncome, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('最新估值') + $t('金额单位')" align="center" prop="valuation" show-overflow-tooltip min-width="100">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.valuation, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('IRR')" align="center" prop="latestIrr" show-overflow-tooltip min-width="100" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>

import { listProjectInvestmentSituation } from '@/api/deal/projectInvestmentSituation/projectInvestmentSituation'
export default {
  data() {
    return {
      total: 0,
      loading: false,
      queryParams: {
        dealType: '',
        dealName: undefined,
        personChargeName: undefined,
        companyName: undefined,
        investName: undefined,
        pageNum: 1,
        pageSize: 10
      },
      dataList: []
    }
  },
  created() {
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      this.loading = true
      if (this.$route.params.dealType) {
        this.queryParams.dealType = this.$route.params.dealType
      }
      listProjectInvestmentSituation(this.queryParams).then(response => {
        this.dataList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    /** 搜索按钮操作 */
    queryHandle() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.companyName = ''
      this.queryParams.personChargeName = ''
      this.queryParams.dealName = ''
      this.queryParams.investName = ''
      this.queryHandle()
    },
    exportHandle() {
      const query = {
        dealType: this.queryParams.dealType,
        dealName: this.queryParams.dealName,
        personChargeName: this.queryParams.personChargeName,
        companyName: this.queryParams.companyName,
        investName: this.queryParams.investName
      }
      this.downLoadExcel('/deal/projectInvestmentSituation/export', query)
    }
  }
}
</script>

<style scoped>

</style>
